export const casinoConfig = {
  // 手续费配置
  fees: {
    winningCommission: 0.05, // 中奖手续费比例 (5%)
    winningMultiplier: 0.95, // 中奖实际获得比例 (95%)
  },

  // 游戏配置
  games: {
    dice: {
      roundDuration: 10 * 60 * 1000, // 10分钟
      minBetGold: 100,
      maxBetGold: 1000,
      minBetSilver: 1000,
      payouts: {
        big: 2, // 大小赔率
        small: 2,
        odd: 2, // 单双赔率
        even: 2,
        triple: 10, // 豹子赔率
      },
    },
    chibi: {
      roundDuration: 10 * 60 * 1000, // 10分钟
      minBetGold: 100,
      minBetSilver: 1000,
    },
    rockPaperScissors: {
      minBetGold: 100,
      maxBetGold: 1000,
      minBetSilver: 1000,
    },
  },

  // 定时任务配置
  scheduler: {
    newRoundInterval: "0 */10 * * * *", // 每10分钟
    closeRoundInterval: "0 */10 * * * *", // 每10分钟
    settlementInterval: "*/5 * * * * *", // 每5秒
    cleanupInterval: "0 2 * * *", // 每天凌晨2点
    healthCheckInterval: "0 * * * *", // 每小时
    wsHealthCheckInterval: "*/30 * * * * *", // 每30秒
  },

  // Redis配置
  redis: {
    keyPrefix: "casino:",
    ttl: {
      roundInfo: 60 * 60, // 1小时
      userBalance: 5 * 60, // 5分钟
      rankings: 10 * 60, // 10分钟
      gameState: 30, // 30秒
    },
  },

  // 数据库配置
  database: {
    maxConnections: 20,
    connectionTimeout: 30000,
    acquireTimeout: 60000,
    timeout: 60000,
  },

  // WebSocket配置
  websocket: {
    namespace: "casino",
    cors: {
      origin: "*",
      methods: ["GET", "POST"],
    },
    pingTimeout: 60000,
    pingInterval: 25000,
    maxHttpBufferSize: 1e6,
  },

  // 日志配置
  logging: {
    level: "info",
    maxFiles: "14d",
    maxSize: "20m",
  },

  // 安全配置
  security: {
    rateLimit: {
      windowMs: 15 * 60 * 1000, // 15分钟
      max: 100, // 限制每个IP 15分钟内最多100个请求
    },
    jwt: {
      secret: process.env.JWT_SECRET || "casino-secret-key",
      expiresIn: "24h",
    },
  },

  // 监控配置
  monitoring: {
    metrics: {
      enabled: true,
      port: 9090,
    },
    health: {
      enabled: true,
      path: "/health",
    },
  },
};

// 环境变量配置
export const getCasinoConfig = () => {
  return {
    ...casinoConfig,
    redis: {
      ...casinoConfig.redis,
      host: process.env.CASINO_REDIS_HOST || "localhost",
      port: parseInt(process.env.CASINO_REDIS_PORT || "6379"),
      password: process.env.CASINO_REDIS_PASSWORD || "",
      db: parseInt(process.env.CASINO_REDIS_DB || "0"),
    },
    database: {
      ...casinoConfig.database,
      host: process.env.CASINO_DB_HOST || "localhost",
      port: parseInt(process.env.CASINO_DB_PORT || "3306"),
      username: process.env.CASINO_DB_USERNAME || "root",
      password: process.env.CASINO_DB_PASSWORD || "password",
      database: process.env.CASINO_DB_DATABASE || "casino",
    },
  };
};
